<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <script src="./js/earthsdk.js"></script>
    <title>Cesium地球初始化</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <script>
        try {
            /** ---------------------------------地球创建------------------------------------**/
            // Vue中引入方式：import { ESObjectsManager } from 'earthsdk3';
            const { ESObjectsManager } = window['EarthSDK3']
            const { ESCesiumViewer } = window['EarthSDK3_Cesium']
            // const { ESUeViewer } = window['EarthSDK3_UE']

            const objm = new ESObjectsManager(ESCesiumViewer);
            window.g_objm = objm;

            const container = document.getElementById("app");
            // 创建Cesium视口
            const viewer = objm.createCesiumViewer(container);

            viewer.ionAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NWNkNmNmNi0xNWMyLTQ3NGYtYjI4Ny01Mjc2ZGE4NGQxNWMiLCJpZCI6Mzg3NTMsImlhdCI6MTYwNjc5NDUwOX0.SIxmCg6USCh-b6mRyuSrWnxqMvUMbVwYrsSVTpi0H0k"
            // 监听视口状态
            viewer.statusChanged.don(status => {
                switch (status) {
                    case "Creating":
                        console.log("视口正在创建");
                        break;
                    case "Created":
                        console.log("视口已创建");
                        break;
                }
            })
            // 通过json创建一个影像图层
            const imageryLayer = objm.createSceneObjectFromJson({
                "id": "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
                "type": "ESImageryLayer",
                "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
            });
        } catch (error) {

        }

    </script>

</body>

</html>